# 测试后端服务状态
Write-Host "=== 测试后端服务状态 ===" -ForegroundColor Green

try {
    # 测试基本连接
    $response = Invoke-RestMethod -Uri "http://localhost:5252/api/log/statistics" -Method GET -TimeoutSec 5
    Write-Host "✓ 后端服务正常运行" -ForegroundColor Green
    
    # 测试日志列表
    $logsResponse = Invoke-RestMethod -Uri "http://localhost:5252/api/log/list?pageSize=1" -Method GET
    Write-Host "✓ 日志列表API正常，总日志数: $($logsResponse.total)" -ForegroundColor Green
    
    # 测试清理API（不实际删除）
    $testDate = (Get-Date).AddDays(-1).ToString("yyyy-MM-ddTHH:mm:ss.fffZ")
    Write-Host "测试清理API，日期: $testDate"
    
    $cleanResponse = Invoke-RestMethod -Uri "http://localhost:5252/api/log/clean?beforeDate=$testDate" -Method DELETE
    Write-Host "✓ 清理API正常，响应: $($cleanResponse | ConvertTo-Json)" -ForegroundColor Green
    
} catch {
    Write-Host "✗ 后端服务测试失败: $($_.Exception.Message)" -ForegroundColor Red
    if ($_.Exception.Response) {
        $statusCode = $_.Exception.Response.StatusCode
        Write-Host "HTTP状态码: $statusCode" -ForegroundColor Red
    }
}

Write-Host "`n=== 测试完成 ===" -ForegroundColor Green 